package com.monster.servlet.detail;

import com.monster.pojo.Playlist;
import com.monster.service.InfoService;
import com.monster.service.InfoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/music/playlist")
public class PlaylistServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        InfoService is = new InfoServiceImpl();
        if (id != null) {
            Long playlistId = Long.parseLong(id);
            Playlist playlist = is.selectPlaylistByPlaylistId(playlistId);
            request.setAttribute("playlist", playlist);
        }
        request.getRequestDispatcher("playlist-detail.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
